package com.harlan.viewbindingstudy;

import android.content.Context;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.harlan.viewbindingstudy.databinding.RecyclerviewItemBinding;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;


class ComAAdapter extends RecyclerView.Adapter<ComAAdapter.ComViewHolde> {
    Context context;



    public  ComAAdapter(Context context) {
        this.context = context;
    }



    @NonNull
    @Override
    public ComAAdapter.ComViewHolde onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        RecyclerviewItemBinding    binding = RecyclerviewItemBinding.inflate(LayoutInflater.from(context), parent, false);
        return new ComViewHolde(binding);
    }

    @Override
    public void onBindViewHolder(@NonNull ComAAdapter.ComViewHolde holder, int position) {
        holder.nametv.setText("第" + position + "项");
    }

    @Override
    public int getItemCount() {
        return 6;
    }

    class ComViewHolde extends RecyclerView.ViewHolder {
        TextView nametv;

        ComViewHolde(RecyclerviewItemBinding itemView) {
            super(itemView.getRoot());
            nametv = itemView.nametv;
        }
    }
}
